With regard to forms, like login prompts, I don’t know the answer, but I’m guessing QWERTY. That is to say, it’s a hold-over from an earlier era for reasons that are obsolete now, but it has become such a de facto standard that users expect it. For many decades, if not hundreds of years, forms were sorted and filed alphabetically by last name (surname). I don’t know why, but maybe knowing the last name narrows the possibilities more than knowing the first (given) name. Or maybe family relations were considered important, so they wanted family members sorted next to family members. Or maybe it was because in those days last name was consider the appropriate form of address in business relations (as in "Dear Mr. Washington:" not today's "Welcome back, George.")
Whatever the case, when forms were strictly paper, the same form that someone filled out is the same physical form a clerk would file, retrieve, and sort. Thus, I speculate, the last name appeared first at the top of the form in order to facilitate the clerk’s work. It’s “clerk-centered design.”
Today there’s no reason for this since the clerk can have a different UI than the form-filler. Indeed, for login and addressing deliveries (such as in ecommerce), first name first makes more sense since that’s how we usually write our names, including for addressing mail. Of course, there’s really no need for separate first and last name text boxes for such purposes either.
In fact for addressing deliveries, it would probably be easiest for the user to have a single free-form multi-line text box for name and address combined. Users hand-address letters all the time, and the mail gets to its destinations. A free-form text field would go a long way to accommodating variations in names and addresses (e.g., for internationalization). If the marketing wants details about the form-filler, let them write an algorithm to extract surname or zip code or whatever from the free-form field. Don’t make it a problem for the user.
But we have different fields in certain orders, because that’s traditional, and users expect it, so why change?