In both world wars who had the biggest guns on a ship was insanely important, it was a race to make the biggest battleship with the most, biggest guns,
Nowadays basically no navy has battleships in active service, what happened that made everyone ditch the idea of big gun on big ship = good?
Airplanes happened.
Before World War Two proponents of air power and of traditional sea power would argue over whether airplanes can sink a maneuvering and defending capital ship. Those two factors, maneuvering and defending, are crucial here, since obviously you can have a stationary battleship without any crew and start dropping bombs on it. Eventually it becomes a question of unleashing a sufficient amount of explosives with sufficient accuracy. If the ship has no damage control parties, if it has no antiaircraft defenses to at least try and make the aviators' job more difficult, there's no hope.
World War Two proved conclusively that a battleship on its own is too vulnerable. One might instinctively point to the raids at Taranto and Pearl Harbor as examples, but those, again, were cases of stationary ships coming under attack. A more fitting example would be the battle of Kuantan, where two Brtitsh capital ships, despite being able to maneuver freely, were obliterated by the Japanese, who lost six (six!) airplanes. On top of that the British lost more than 800 men, the Japanese, only 18.
As the war progressed, the vulnerability of battleships to aircraft became increasingly apparent, culminating in the destruction of the Japanese Yamato and Musashi.
In the end, it became a question of resources. Each ship is 40 or more thousand tons of resources, stupendous amounts of money... and for what? An investment of this magnitude should become a strategic asset in your arsenal, but in the end (and I'm simplifying a bit) a navy would need to use aircraft carriers to provide escort to the battleships (protection from enemy aircraft), when the carrier had already been proven to be more capable on its own and could engage targets at far greater ranges by simply using its air group directly.
Furthermore, while the battleship can be useful in missions such as shore bombardment, it will no longer be possible to use it for what it was conceptually optimized to do: engaging enemy warships (or, to be more precise, enemy battleships). Therefore, if you have the resources and know-how to build a battleship, just redirect all of that to building an aircraft carrier. There is nothing that a battleship can do which a carrier air group could not.
On top of thar came the advent of nuclear weapons. As the major powers reoriented themselves to a new era of warfare, they had to account for the enemy having nuclear warheads. Bombs, yes. Ballistic missiles, yes. But also nuclear tipped torpedoes. Thus, the supposed strategic asset was not only cumbersome and proportionally less potent, but also vulnerable to an even greater arsenal of weapons than before. There would have simply been no sane justification to start building new battleships after WW2.
Edit: I am going to add a bit about the big gun on big ship = good part. This idea, in fact, has not been totally ditched, because big guns are still a powerful weapon. The USS Missouri and USS Wisconsin used their big guns as late as 1991, during Operation Desert Storm (along with Tomahawk missiles, the launchers for which were added in the 1980s). They might be, as I said, proportionally less potent, but those were still big guns with big shells mounted on ships with thick armor.
And in fact, modern anti-ship missiles are designed to counter vessels built to a completely different philosophy. They’re supposed to strike low above the water and punch through a relatively thin “skin” into the hull. This in turn means that battleships such as the Iowa class would have been almost entirely invulnerable to weapons such as the Harpoon or Exocet, or RBS15 missiles.
The Iraqis during Desert Storm tried to engage one of the American Iowa-class battleships with their Chinese-made ASMs. The battleship was successfully defended by the British frigate HMS Gloucester, but had the Gloucester not been there, the Missouri could have just taken those two missiles into her side without any danger to her seaworthiness.
The point, again, is money and other resources. It’s possible to use an old-timey, albeit upgraded, battleship in a modern battlespace. So, if you have a few battleships lying around and you want to put them back to service as a propaganda symbol (as that is essentially what happend to the Iowas), you might as well use them. But you are not going to specifically build a brand new battleship (remember: 40 thousand tons of stuff) just to have it do what you can just as well do with other ships and aircraft for much less money.