The thing to remember ultimately is that battleships were direct descendants of 18th and 19th century wooden ships of the line. There had been an evolutionary process that entire time that refined/morphed the 74 gun 3rd rate into the Iowa class. It was punctuated by fairly large watershed moments- the adoption of steam, the adoption of armor, all big gun armament, and the use of radar.
So as a result, that was basically how they were intended to be used- essentially to line up and fight it out with other battleships, Trafalgar-style. And with the corresponding casualties.
But where a single 74 wasn’t that much of an investment relative to the entire British naval budget of say… 1808, a single battleship was a huge investment in a nation’s 1925 naval budget. And it was shown in WWI that they were vulnerable to other much cheaper systems- torpedo boats and submarines.
There were capital ship engagements in WWI between battleships- the Battle of Jutland being the largest and most famous. And they ended pretty much how you’d expect- bloody and somewhat inconclusive, since battleships were both heavily armed and armored.
So we ended up in WWII with a situation where the battleships were considered some combination of too valuable and too vulnerable to really use as the core of a naval fleet. It is true that there were some surface actions where battleships fought each other- the naval battles around Guadalcanal had a handful of American battleships fighting a handful of Japanese battleships, and later in the war, the Battle of the Surigao Strait, where US battleships defeated Japanese ones.
But for the most part, early war events had shown that battleships were generally horribly vulnerable to aerial attack- Pearl Harbor, the sinking of the Marat, the damage to the Bismarck by torpedo-bombers, etc… so commanders were reluctant to use them outside of their own protective aerial cover.
Eventually, the Japanese battleships were sunk piecemeal by aerial attacks, and the US ones were relegated to the role of shore bombardment for amphibious assaults.
To answer the question directly- they DID use them in WWI, only to find out that they were more vulnerable to other sorts of weapons when outside their own fleets (i.e. without destroyers), and in WWII, they were too vulnerable to air, submarine, torpedo boat and destroyer attacks to be used outside of a major fleet action. But in both wars, they were colossally expensive, and therefore weren’t used as much as you might have thought, especially after early-war examples of the utility of naval aviation/aircraft carriers,