This is a configuration issue, and not any kind of a limitation of the device or software:
- An iPhone can be configured to ask you if you want to join unknown WiFi access points in your area. If your phone is doing this, you can (and should!) go to Settings and reconfigure it so that it no longer asks. It's just good security practice to only connect to public WiFi when you actually have a need to do so and when you're reasonably certain of the nature of the access point -- and even than, it's best to use a VPN when on any public access point, if at all possible.
- An iPhone is also configured by default to automatically join "known" networks. That is to say, even if you have turned off the "Ask to join..." setting, if you have previously connected to any given network, the device will no longer ask -- it'll just go right ahead and join that network. Of course, this can be especially annoying if that network inserts some form of a verification page or paywall page into the connection process, which many stores and coffee shops tend to favor. You can eliminate this behavior by telling your phone to either not automatically connect to that particular access point anymore, or by telling it to forget that access point entirely.
(As an aside: while I don't personally have specific experience with dealing with this issue on Android, it reportedly behaves in much the same fashion and likewise has similar configuration options.)