Well, to be a “physicist or astronomer” you would have to finish the PhD, possibly a few postdocs, and then to get one of those annoyingly difficult academic/government/industry research positions in the field. So you’re looking at people in their 30’s, which means that you are comparing that median to engineers that are about a decade younger. Compare that number to “median pay for engineers with at least 10 years of experience” and you will find a much less flattering comparison.
Academic careers like physics are not worth it financially because anyone talented enough to become what is called a physicist could easily excel at the relatively easy stuff you get paid for as an engineer in industry (the prerequisites for that work far, far exceed the actual brain work it takes to do those jobs). You do it for non-financial reasons, such as the desire to do physics for a living. It’s a pretty bum deal to go that route, whether or not it sounds more interesting, if it doesn’t offer you a solid living. A somewhat reduced salary is a given, but it shouldn’t be a vow of poverty like it has a tendency to be nowadays.