Your phone uses one of two ways for online access, either WiFi or cellular. They are both wireless signals but are two completely different types of wireless connectivity.
-- WiFi signals are relatively weak with an effective range of a few hundred feet or so. Your home router emits the WiFi signal for your home network. Your router is connected to your ISP's modem and the modem is what is indirectly connected to the Internet. WiFi is often identified as 2.4 GHz or 5 GHz, both being direct references to the bandwidth frequency each on occupies (i.e. channel 11 in 2.4GHz is 2462 megahertz, channel 1 is 2412 megahertz)
-- Cellular signals are pretty robust and have a coverage range of a few miles. They are emitted by cellular towers/cellular access points scattered everywhere. All of those are fed their signals by nation-wide cellular networks, and those are indirectly connected to the Internet. Cellular can be differentiated by progression levels -- 2G, 3G, 4G/LTE, 5G -- a marketing abbreviation for 2nd Generation, 3rd Generation, etc.
Some people mistakenly merge both together since both are wireless and oddly because there's a common letter G in those identifiers but in reality they are two very different types of wireless connectivity. If you do prefer to consider both the same, that makes your problems with online connectivity a lot harder to fix.
In your instance, there's not really a problem. It's a just a typical way smartphones work -- when your phone is receiving both a good WiFi and a good cellular signal, the preference is to prioritize WiFi over cellular. Just disable WiFi or disable mobile data in accordance to what your need. (disabling mobile data doesn't cut off cellular connectivity, it just stops any active data exchanging over cellular. A very low bandwidth cellular connection still remains so you still can receive and send phone calls, and SMS texts.)