I think it's because it damages blacks pawn structure. Bobby Fischer used to play the exchange Ruy Lopez and just trade into an endgame that he was better due to blacks doubled pawns
Nimzowitsch Defence Pseudo-Spanish Variation
if you play the Spanish you can play this but it would be better to grab the center with 2 d4 or to allow Black to transpose to the Open Games with 2 Nf3

My engine doesn't say a6 is an inaccuracy but it doesn't really matter anyway because after 3. Bxc6 dxc6 4. nf3 e5 it just transposes into the Exchange variation
Ba4 is an "inaccuracy" because it doesn't actually do anything to prevent black from playing 3. d5 (Which isn't reasonable after 1. e4 e5 2. nf3 nc6 3. Bb5 a6 4. Ba4 d5 just looks awful). If exd5, just qxd5 and it centralized the queen with tempo on g2 (So 5. nc3 isn't possible). White is practically forced to play qf3 which just leads to a very nice position for black after the queen trade. So after d5, white's best choice is to play Bxc6+ and e5, which means white has wasted a tempo for no reason in the opening
1 e4 Nc6 2 Bb5 d5 is good for black: 3 exd5 Qxd5 attacks both Bb5 and g2
2...a6 3 Bxc6 dxc6 4 d4 is good for white. It is possible as there is no pawn at e5.
3 Ba4 d5 is equal

For the Real Spanish Opening most Grandmasters say Ba4 is better than Bxc6 because it keeps the bishop pair. Stockfish seems to agree with this.
I have just done Depth 50 analyses with Stockfish 14 on both the Real Spanish Exchange and the Pseudo Spanish Exchange.
Pseudo Spanish Exchange:
Drops to 0.00 on 2.Bb5, 2...a6 +0.15 3.Bxc6 +0.11
Open Variation:
3.Ba4 -0.34
Real Spanish Exchange:
4.Bxc6 +0.01
Open Variation:
4.Ba4 +0.40
#6
You cannot rely on engines is the early opening: the positions are way to complex for a meaningful evaluation within the calculation horizon. Engine evaluations become accurate once about 26 men are left on the board.
It is not sure that 4 Ba4 in the real Ruy Lopez is better than 4 Bxc6. Lasker, Capablanca, Alekhine, Fischer, Bronstein all played 4 Bxc6 giving up the bishop's pair so as not to lose a tempo and to gain a better pawn structure.
Steinitz and Lasker argued that 3...a6 in the real Ruy Lopez is weakening and loss of tempo and reasoned 3...d6 respectively 3...Nf6 is superior. Kramnik and AlphaZero concur.

For the Real Spanish Opening most Grandmasters say Ba4 is better than Bxc6 because it keeps the bishop pair. Stockfish seems to agree with this.
I have just done Depth 50 analyses with Stockfish 14....
Depth 50?! Interesting.
GM Kiril Georgiev, opens his "Fighting the London System" with the following:
Are you still curious what are the best openings for White? I have an answer for you: almost any normal development! At depth 50, modern engines evaluate most main lines as 0.00! Suppose that I want to build a repertoire against the Slav. I have tried everything against it and I assure you that the Meran is 0.00. I have also tested the Botvinnik Variation. The most principled lines follow a very narrow path, reaching 0.00 well after move 40. The same applies to the Queen’s Gambit etc.
For whatever it's worth, the fact that you evaluated those openings at close to 0.0 at depth 50 is good supporting evidence for Georgiev!

It's a mistake plain and simple. Unlike the the Spanish,black has not committed his pawn structure, so it remainsto be seen if doubling black's pawn is advantageous at the concrete cost of a bishop pair. It most likely isnt if you are familiar with the many ways to play the declined Nimzowitsch defense.2 a6 may not best but it is ok. 3.ba4 is just the best move from your opening error although after b5 sooner or later, the bishop on b3 will look a little ridiculous after safe move like e6. I would personally go for a b5, nf6 e6, na5 and bb7 formation here. Black now get a nice Sicilian like structure without white's bishop pair.
2 ... a6 actually seems to be a mistake. It hasn't been played many times at high level, but in *none* of those games did black actually win. 2 ... d5 is an oddball move that has been successful a few times, but honestly it looks as though the main line (2 ... Nf6) or the most common alternative (2 ... e5) are probably the best options.
I recently played a game as White that started like this:
I had never played this opening before but recognized the idea of playing Bb5 from the Spanish opening.
After the game I looked at the engine analysis and it said both the a6 and Ba4 moves were suboptimal. It says Bxc6 is best.
But in the Spanish opening Ba4 is the main line.
The only difference is there is not yet a pawn on e5 and not yet a knight on f3.
Why do those differences mean capturing the knight is better here?