I checked the WordPress source code, and this issue shouldn’t be happening.
Yes, str_contains is a PHP 8 function. But WordPress includes some code so it creates it’s own version of str_contains if it’s not provided by PHP, to ensure compatibility with older PHP versions.
If that’s not loaded, I suspect that there may be some code corruption in your WordPress installation. So you may want to try if this fixes it: