My goal is to connect the Raspberry to a machine via a network switch and then use the Raspberry to pass the data to internet via its wifi.
Before I started any connection, I am testing the Raspberry. The Raspberry can connect to internet using wifi or talk to a switch, but it cannot do both at the same time. For example, I will lose connection of the wifi if I connect the ethernet cable. How to fix it?
To get you going, I suspect that default setup is to use the ethernet connection for internet if it is available. You may need to setup a default route or something, but I don't know. So best to ask on a Pi forum I think.
As Colin says, you won't find much help on that here I'm afraid. For starters, we don't know anywhere near enough about what you are trying to do or about the environment in which you are working and the value of your system and data.
Secondly, configuring Linux to handle multiple interfaces is certainly a question for a different forum. You might try one of the Stack Overflow forums for example.
Thirdly, just because you can, doesn't necessarily mean you should. Make sure that, when messing with networking, you don't accidentally allow inbound connections from the Internet.
By the way, when asking questions elsewhere about the Pi, you can use often use general Linux forums too, just note that the Pi OS's are all (or mostly) based on Debian Linux.