As I mentioned this is a bug in MAMP PRO making mamp unable to understand that opcache is actually on, it thinks it's off and when you save the changes it will literally get off. We can leave that to off, but enable opcache ourselves, that way everything will be solved.
First click on Open template so you can open php.ini for your current php version.

First copy the whole content of this file and get yourself a backup of it.
in the opened editor you can search for opcache and you'll find a section about it, comment it all and enable the options you want, make sure you set opcache.enable=1
[opcache]
;MAMP_OPcache_MAMPzend_extension="/Applications/MAMP/bin/php/php8.1.1/lib/php/extensions/no-debug-non-zts-20210902/opcache.so"
; Standard settings, see below for detailed explanation
; opcache.enable=1
; opcache.enable_cli=1
; opcache.memory_consumption=128
; opcache.interned_strings_buffer=8
; opcache.max_accelerated_files=10000
; opcache.revalidate_freq=2
; opcache.fast_shutdown=0
; opcache.jit_buffer_size=100M ; needs opcache.enable=1
; opcache.jit=1255
opcache.enable=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=80
opcache.max_accelerated_files=100000
opcache.enable_cli=0
opcache.jit_buffer_size=150M ; needs opcache.enable=1
opcache.jit=1255
Now from the second line of the above block, you can find
;MAMP_OPcache_MAMPzend_extension="/Applications/MAMP/bin/php/php8.1.1/lib/php/extensions/no-debug-non-zts-20210902/opcache.so"
That's what we need to enable opcache manually just omit ;MAMP_OPcache_MAMP
and you'll get something like
zend_extension="/Applications/MAMP/bin/php/php8.1.1/lib/php/extensions/no-debug-non-zts-20210902/opcache.so"
Great, all you have to do now is to put this at the end of your editor.

Close the editor and save it, now turn off the opcache in the UI if it's on, and you'll still have it on, you won't get an annoying warning and saving won't turn it off anymore.
If you ever wanted to disable opcache just comment that last line that you added in the editor.