Obviously, two or more people or things occupying one boat must share equal risks, and the phrase “to be in the same boat” has thus acquired such figurative meaning; to share risks equally, to have identical obligations or involvements, to be in or live under similar conditions.
Literary usage of the phrase goes back only about a hundred years, but it may have had its origin in an older expression, by three centuries, “to have an oar in another’s boat,” that is, to interfere in or meddle with the affairs of another.