This little problem that you have put your finger on has bedeviled musical traditions for some millenia.
Read all about it in why it's fundamentally impossible to tune a piano perfectly and equal temperament.

Also notice that it is somewhat dangerous to call the temperament you were using traditional western, since from the Middle Ages to now we have gone through at least three temperaments, namely just intonation that was substituted around 1500 by the meantone temperament, now largely superseded by the equal temperament.