There are many conventions and they are mostly field dependent. I'll try to list a few of them, along with a bit of the possible reasoning. I'll also give some personal preferences about such questions, but they are, perhaps, influenced by my own education and career.
In pure math and theoretical computer science, authors are generally listed alphabetically. The intent is to say that all contributed equally to the ideas, if not to the (quantity of) work itself. A seemingly minor comment in a meeting can lead to a big insight in a paper. My experience in those fields is that advisors don't add themselves to the list of authors, though I'd guess there are exceptions. Perhaps many. I'm very uncomfortable with a convention that the advisor is always an "author" even if they contribute very little.
My personal practice (math, CS) is that I won't be a co-author with a student on their thesis work, even if I contribute the problem and give them extensive advice along the way. The work that solves the problem is theirs. And while I prefer alphabetical listing of authors in work I contribute to, I've been on at least one paper that followed a different convention since two of the group were the clear drivers of everything in the work. And the person among us who actually put the words in place was not one of the "first" authors, just the best writer.
Note that collegial relationships such as I just described makes it desirable to work with those same authors on future work. So, while I might be a "minor" author on a work, those people are happy to work with me in the future.
In some lab sciences author order is considered very important but the convention varies. In some, the advisor is always listed last in order, but some people assume they did all the "real" work and just carried the other along. In some fields, the advisor is listed first, with the same idea behind it.
In those fields that list advisors on student works it is sometimes justified by noting that the paper may get more visibility if a prominent name is among the authors. The association with that person might also have some value. But such can also be indicated in other fields by having an acknowledgement section, thanking advisors or others who helped but are not authors.
In those fields in which the advisor adds themself by convention, it may make sense or not. If the field, such as a lab science fundamentally depends on grants written by and labs managed by PIs, it may make sense since many of the ideas developed in such a lab may flow from meetings in which the PI is a fundamental participant.
Note, however, that it should be the case that the authors are the ones that contribute ideas to the papers, not just "work". Someone can spend a lot of time and effort on a paper that is actually driven by the ideas of others. But I think that idea is not especially well followed, certainly not universally.
In those fields that worry about and fight over author order, relationships can be destroyed when people bicker over priority. It is, in my view, a selfish attitude.
However, having said all that, looking at a particular paper, it can be difficult to know from the list of authors alone who was the primary driver of the ideas. A few of the authors in a longer list might have been more or less equal contributors. Some fields will explicitly list "co first" authors if they feel it is important, though it may not be obvious from the listing and you might need to get the paper to see if it has a section or note on contributions.
It should also be noted that there are several papers with thousands of "authors". The list of authors is longer than the paper itself. CERN produces such papers, for example, just by the nature of the work there.
I hope I didn't go too far off-topic here, but these are things that I think a new academic should consider. Be generous with your colleagues.