Well I am not able to understand why is this happening? When I connect to a particular router this continuous state of switching happens and there is no problem with other routers. What are the possible reasons of this? How to avoid it happening?
I had experienced a problem with wifi tethering of my device and this solved my issue. Go to settings(Data Settings), there may have an app (I am using Xiaomi device and I have Security app which controls this) that restricts data usage for all applications(both wifi and internet). In that, there is system app named "Android System" which controls wifi and tethering.
Please check whether it provided with data and wifi access.