If your phone has a data pack activated and you have 1st swtchon the mobile data, then when you go for the wifi, it will get connected and the present connection will be Wifi connection.
Similarly, if you swtchon the wifi 1st, then mobile data, the mobile data will be connected in the present.
You can't swtchon both at the same time, not possible. There has to be a gap, whichever you swtchon, that will work and the previous one will disconnect automatically.