In the U.S., in at-least-moderately research-oriented universities, I have the impression that faculty creators of course notes/texts have the copyright (until they make some possible deals with publishers), rather than the institution. This is explicit in my university's policy statements. The corresponding question about adjuncts or contractors hired specifically to create course material seems not (currently) relevant, because I've not seen that happen (in mathematics).
(IANAL, but, ...) In the U.S., there is a notion of "work for hire" (writing/creating something specifically requested by an employer as the central part of one's job), in which case copyright or corresponding rights are by default owned by the employer.
In the case of research-oriented faculty who have no obligation (and won't be rewarded at all for it) to create course materials, I think the current interpretation is that any course material creation is voluntary (and probably not terribly profitable), so they keep the copyright.
I know many people who've created course notes (for mathematics), perhaps most enthusiastically upper-division or grad-level or further, though I've put calculus notes on-line, myself. Doing this, obviously one does not expect profit or control. Many people who've published conventional physical books also have negotiated with publishers retention of copyright + rights to keep things on-line (sometimes with an "embargo" period).
20-30 years ago, when the internet was still embryonic, it was not clear how it would work, and people did worry about "getting credit", and/or profit, and/or people "stealing" their work. (Yes, there do exist TeX decompilers, so not putting the TeX source on-line does not prevent people from recovering the source code, and so on.) Sure, one can try "watermarking" or other steganographic tricks, but, ... Since my university does not consider anything on-line to have any status-enhancing features, anyway, I decided to stop worrying about people "stealing my ideas". Better to spread (hopefully!) good ideas and "not get full credit" than be secretive and be of no help to anyone.