What were the similarities between the Spanish-American war and the wars in Iraq and Afghanistan?
For the United States, there was not much similarity between the Spanish-American War itself and the more recent wars. There were similarities between the wars in Iraq and Afghanistan and the US war in the Philippines that followed the Spanish-American War. There were some similarities between the Spanish war with Cuban insurgents and the recent wars, but the conflict between the Spanish and the Cubans was not part of the Spanish-American War. Therefore, I will discuss some of the similarities between the US war in the Philippines and the wars in Iraq and Afghanistan.
The major similarity is that all of these wars were/are guerrilla wars. The US is/was fighting with regular troops not against other armies but against guerrilla forces. In all cases, the opposition was in no way able to engage in stand up fights against the US, but they were able to frustrate the Americans with guerrilla tactics.
A second similarity is that, in both cases, the US was being opposed by forces who saw the US as occupiers while the Americans saw themselves as liberators. In the Philippines, the US believed it was liberating the islands from the Spanish, but the insurgents felt that the US was occupying them and denying them freedom.
Thus, in both the war against the Filipinos and the wars in Iraq and Afghanistan in recent times, the US was/is fighting against guerrilla fighters who perceive the US to be an occupying force.