wifi is getting turned off and mobile data is getting turned on automatically
There is an option in the Wi-Fi settings:
Keep Wi-Fi on during sleep

It has the following options:
-> Always
-> Only when plugged in
-> Never

Make sure the above is set to "Always".
I believe it will have set "Never" in your case.