While the phone is connected to this Wi-Fi that needs log-in, it's keeping the Wi-Fi module busy. The phone can't scan for other Wi-Fi networks. Apps might see that there's a Wi-Fi connection and try to use it, expecting to get the Internet but actually just burning power for nothing. The phone also disconnects from mobile data while a Wi-Fi connection is active (though this is just from the way it's designed).
Disconnecting from the useless Wi-Fi connection keeps the mobile data connection alive, so you still have Internet access. Apps aren't trying to use a connection that's useless to them. And it lets the phone keep scanning for other networks, which you might be able to use without log-in.
I don't understand why you want to "solve this problem": everything works as designed. When you use the "Sign into Wi-Fi network" notification, the phone can immediately reconnect and you can sign in and get a working connection. Automatically disconnecting from captive Wi-Fi portals lets your phone keep working before you're ready to sign in, and it doesn't stop you signing in when you're ready. There's no problem at all.
If you want to sign in automatically, avoiding the disconnect and reconnect entirely, we have a very old question about signing into captive portals, but I'm not sure if the answers are still relevant to newer Android versions.