The head contains general information about the whole document.
The body contains the content.
A stylesheet isn't the content, it is information about how the content should look.
A script element going at the end of the body is a performance hack.
It is allowed in the body in the first place because it can inject content directly into its current position (with document.write), although that isn't considered good practice today.
I would typically put the <script> in the <head>, but set the async attribute and use a DOMContentLoaded event listener to make it run when the content has loaded.