This is (of course) a Scottish saying: basically the point is wishes are useless. It's that simple.
It's one of those interesting phrases where there are very many versions of the phrase. They all start with "If wishes were fishes..." And indeed, the best version is to just say "If wishes were fishes..." and leave it at that.
Anyone who grows up Scottish is constantly told, "I cried when I had no shoes until I saw a man who had no feet" and "If wishes were fishes..." and other gems like "shut up and work harder," possibly with coarser language.
As you can see, the overwhelming point is "shut up and work." "If wishes were fishes" is an admonishment your Scottish grandmother screams at you, if you are lazy. That is, if you sit around saying things like "if only I'd gotten a degree" or "if only pizza was cheaper", your grandmother will scream at you "If wishes were fishes, laddie — now get up off your backside."
"This phrase doesn't make any sense to me" -- you're referring to the version "If wishes were fishes we'd all swim in riches"
It couldn't be clearer. The second phrase "we'd all swim in riches" means "We'd all be rich". Right?
The first phrase "If wishes were fishes" means if magic was real, if wishes were real, if prayers were always answered, if hope was worth anything. (Fish are plenty and real.)
The expression is used to express the pointless futility of wishing for something. It's simply saying: "if idiotic wishes/prayers/dreams/hopes were real, we'd all be rich. So, shut up and start moving your hands so that you are cleaning the floor."