in MacOS there is no unified way to get to the beginning or end of a line. In Linux and Windows this is done with the Home and End keys. In Mac, there are some shortcuts but they are not universal, what works in terminal may not work in a browser textarea and so on. Some programs interpret the same shortcut as "go to the very end of the text (as in a PgDown key) but that same shortcut, in another program, might go to the end of the line (like the End key).
Please let me know if I'm missing something! Every time I make a web search about this topic, I end up in various pages like this one[1] with shortcuts that don't work for me for the reasons explained above.
EDIT: I found out that there are some Mac keyboards with the Home and End keys. So it seems that this is not an OS issue but, I guess, a MacBook issue (I've only ever used MacBooks and always without external keyboard).