It looks like you are trying to put php code inside a .htm or .html file.
I ran this code as just html and got the following:
Hello World
'; ?>
So, it is properly interpreting the <p></p>
tags but everything else is meaningless to it and doesn't know what to do with what comes after it, so it just prints it as is.
To use php, you need to be doing it inside a .php file and you need to be accessing it from a server that recognises .php files. If you are doing this locally, simply opening the file in a browser won't work by default. You will need to setup a local web server that is running a version of PHP. if you don't have much experience, I recommend WAMP because it is easy to set up and run php with.
If you are doing this on a website that is actually hosted (not local), most of them have support by default for PHP, so if you are using a .php file and it isn't working, you should contact the host or read their documentation to figure out how to get their servers to interpret php files.