iPhone turns off wifi when Lock Screen Active is a bug or a feature?
Problem: VPN app disconnects wifi when the iPhone goes to sleep mode.
         (even when the VPN isn't used)

Solution: remove the VPN.

I think another solution is to use a VPN app that uses IKEv2 (Apple's native VPN framework):

For example, ProtonVPN can do this https://protonvpn.com/support/protonvpn-ios-manual-ikev2-vpn-setup/