Mark Twain hated the concept of imperialism because he realized it was based on hypocrisy and domination, two ways of being he abhorred. As he explains in his essay "To the Person Sitting in Darkness," the American project in the Philippines was to conquer and exploit the country, not free it as one might expect a democratic nation to do.
All through Twain's oeuvre, he takes what is called the subaltern perspective, or the "view from below." He sees imperialism through the eyes of the conquered, not the conquerors, just as he tries, if not always successfully, to envision slavery through the eyes of the slave and not the slaveholder. As an empathic person, he hated to see others suffer for the benefit of the greed of a few.
As he explains in his essay, if the US truly is the beacon of democracy that other nations look up to, it should behave like one by freeing the Philippines and helping it to establish a truly democratic government.
His attitude toward American imperialist policy is similar to his attitude to the King and the Duke in The Adventures of Huckleberry Finn: he sees the hard-hearted con artists and the United States as profiting from a grossly hypocritical and self-serving game.
Twain, like many people opposed to imperialism, believed that American imperialist actions, particularly in the Philippines, were at odds with the putative values of the nation. He spoke and wrote quite often about the subject and was a member of the Anti-Imperialist League, an organization formed specifically to lobby against the annexation of the Philippines. In his satirical essay "To the Person Sitting in Darkness" he made his views on imperialism plain:
And as for a flag for the Philippine Province, it is easily managed. We can have a special one—our States do it: we can have just our usual flag, with the white stripes painted black and the stars replaced by the skull and cross-bones.
Denying freedom to the Filipino people was contrary to America's anti-colonial origins, and the violence and brutality that was used to crush the Filipino uprising was a stain on the national conscience. As he said in a newspaper column in 1900 (about a year before the previously cited essay), "we have gone there [the Philippines] to conquer, not to redeem." Twain decried imperialism in other regions as well. His long essay "King Leopold's Soliloquy" excoriated the King of Belgium for the brutal treatment of people in the Belgian Congo, all of which, Twain made clear, was carried out with the aim of enriching King Leopold and his cronies. So Twain had a deep antipathy for imperialism, which he saw as unbecoming of the United States and other "civilized" nations.
Mark Twain was a member of the American Anti-Imperialist League, along with Andrew Carnegie, Samuel L. Gompers, and others. They were primarily opposed to American acquisition of the Philippines. Their argument, which Twain supported, was that American acquisition of the Philippines undermined democracy itself and violated every principle this country stood for. Additionally, the Monroe Doctrine had held that America's interests were exclusive from the rest of the world, and American imperialist policy violated the Doctrine. They argued that it was inconsistent to free Cuba, which had been done by the Treaty of Paris of 1898, and yet annex the Philippines. Finally, they argued that this could be the "Achilles Heel" of the U.S., as the Philippines would be impossible to defend. Twain's opposition was framed in a famous essay: To the Person Sitting in Darkness
Mark Twain believed strongly in the idea of democracy and in the idea that people should be free. You can see this sort of attitude revealed in many of his books. For example, in both A Connecticut Yankee in King Arthur's Court aned The Adventures of Huckleberry Finn we see Twain showing that he thinks that monarchy and elite rule are corrupt institutions. He shows that he believes that the common people should be give the chance to rule themselves. He clearly believes in the American way.
Twain applied this way of thinking to his thought about imperialism. He did want other countries to become more like America. However, he thought that imperialist countries (including the US at the time) did not mean to try to actually improve the countries that they took as part of their empires. He thought that they, instead, were just trying to exploit those countries. This is why he opposed imperialism. You can see that idea in the following quote from the historywiz.org link below
I said to myself, here are a people who have suffered for three centuries. We can make them as free as ourselves, give them a government and country of their own, put a miniature of the American constitution afloat in the Pacific, start a brand new republic to take its place among the free nations of the world. It seemed to me a great task to which we had addressed ourselves.
But I have thought some more, since then, and I have read carefully the treaty of Paris, and I have seen that we do not intend to free, but to subjugate the people of the Philippines. We have gone there to conquer, not to redeem.