Nothing is going wrong here, but you’re mixing-up two different things. In general two different PHP components are involved here, the web server and the command line component. You’ve only tested the command line (CLI) component. You need to update the web component now too to align both versions.
But when I start nextcloud I get this error:
Internal Server Error
The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.
Such kind of problems are reported on a regular base here. You need to follow the recommendation and check your web server and Nextcloud log files to get an idea of the root cause of the problem. Very often e.g. a php database module hasn’t been installed and Nextcloud cannot be started. If you use the search function of the forum you will find several matches on “The server encountered an internal error”.
Sorry, due to the fact that you were so focused on PHP 7.4 I thought you would have informed yourself on the system requirements and missed that you tried to upgrade from NC 15 to a newer version.
It is essential that you always check which PHP versions are supported by Nextcloud first, before you’re going to upgrade a server, especially if you’re four versions behind. Due to the fact that PHP 7.4 is extremely new only NC 18 currently supports it.