I have written for the purposes of my PhD some very short Python code (110 lines) which I believe could be useful to others. Hence I would like to spread it (e.g. on GitHub) but want to prevent anyone who would use it to make a patent out of it. Thus I found that the Apache 2.0 Licence would be appropriate. So I went on the http://www.apache.org/licenses/LICENSE-2.0 webpage and read in particular the "APPENDIX: How to apply the Apache License to your work". This seems to indicate that there is nothing else to do but copy/pasting the 10 lines of Copyright at the beginning of my code to apply the Apache 2.0 Licence. But I cannot understand how copy/pasting 10 lines of text would give any legal protection to my work. Sorry for the silly question, but I do not know much about copyright and was not able to find a clear answer on the web.
Copyright is automatic when you write the work - see copyright.gov for the US.
Your work is under copyright protection the moment it is created and fixed in a tangible form that it is perceptible either directly or with the aid of a machine or device.
You can license that work to others or not as you wish. The Apache license doesn't give you copyright protection, it lets others use your work without getting sued by you for violating your existing copyright.
So for your case, just add those lines. You may want to distribute the license as well in a LICENSE file.
I cannot understand how copy/pasting 10 lines of text would give any legal protection to my work.
Well this is simple: by adding a notice stating that your code is licensed under the Apache license, you effectively grant a license with conditions. These conditions are the Apache conditions. Therefore any use of your work that would not respect these conditions would not be licensed by you and therefore "infringing" on your rights.