I can think of 3 examples:
1 master and commander, where I believe all enlisted sailors, if addressed directly, are “Mr. last name”
2 pirates of the Caribbean: the character, Mr. Gibbs, who is always dressed as a able seaman, not an officer (or civilian sailor)
3 this book I read as a kid where everyone on board a merchant ship was Mr. last name, except the captain
...
Was “Mr. last name” the way you were to address petty officers and or chiefs in the navy some time ago?
When I looked this up online, all I saw is that sometimes the military still may address warrant or junior officers as such. But I haven’t seen this first hand at all.
So the simplest answer is that is it is to create a distinction between the officers, including petty and warrant officers, and the common sailors. Officers were usually treated as "gentlemen," no matter their actual social standing, some came even from relatively low birth. But when you're on a ship, especially since midshipmen may be years and years younger (think 12 year olds) than some of the able seamen who are fully grown adults and experienced in their trade, they needed to ensure a hierarchy within the ship. It was common to address your peers and even your subordinates as "Mr" but it doesn't work going up, so lt's could not call a captain a Mr, they have to address his rank properly, but he may call his subordinates Mr.
However, you do also have some cases of officers addressing the men by Mr. Lastname, or simply their lastnames, to keep formality and as a sign of respect. Officers would never address the men by first name as one would a friend -that is way to familiar! Fraternization was a big no-no. This is actually still common in the navy even today by some degree.
BTW, Mr. Gibbs was a quartermaster of the ship, much higher standing than an able seaman aboard a ship, especially on a pirate ship by historical standards as that was usually the higher "rank" than a captain. Depends on the ship though, this is a generalization, and we're referring to Disney here...
One of the best sources on this is N.A.M Rodgers' The Wooden World, it describes all aspects of live in the Royal Navy from its beginnings to the end of the Age of Sail.