Weren't blacks enslaved by the Spanish at the time? Weren't natives treated poorly by the Spanish?
Is it appropriate to say these privateers were more egalitarian than pirate crews at the time?
While I can't speak specifically to whether Spanish privateers during that period used non-white shipmen, none of Cuba's history before or after suggests this is unusual.
When Jacques de Sores successfully captured Cuba in 1555, part of the armed group which tried to take the town back was comprised of black and indigenous men. Whites were in the minority and didn't have the numbers to go toe-to-toe with the pirate's fleet (even this combined attempt also failed).
I also recall Jacobo de la Pezuela's multi-volume history of Cuba making occasional mention of indigenous peoples being mobilized to fight off pirate attacks.
As Dr. Maria del Carmen Barcia points out in this article, the Batallones de Pardos y Morenos (Battalions of Blacks and Mulatoes, ie. mixed race) was formed in the 17th century in order to protect the colony from attacks, including pirate attacks. By the period you mention, the early 18th century, Havana itself had four such 'companies' of such soldiers. Barcia takes pains to note that this was simply a form of organizing and recognizing aid which black and mixed race men had contributed in the past defenses of the colony. Such military units and service additionally gave salaries, access to favors/power, and social prestige.
Indigenous peoples, still marginalized and on the slow road to near total assimilation, survived on the margins of society however they could. If someone wanted to hire them to sail, fight, and bring home wealth they'd normally be unable to access, it would certainly be an attractive offer.
Privateering (licensed piracy against enemies of the crown) promised immense wealth within a short period of time, although with the obvious downside of high risk of death or injury. By the early 19th century, mixed race privateers, based in Cuba, attacking pirates and enemy privateers, was normal. I'm far less familiar with how true this was in the early 18th century, however.
You make a point of the fact that both indigenous peoples and black people were treated poorly. This is correct. The contradiction may seem insoluble, but it is a far more common phenomenon than you'd think.
Many of these men were born in Cuba. The King of Spain was their king. They could not overturn the existing social order, of which they were victims. They could, however, try to survive within it. Some could even acquire a sense of patriotism (ie. sense of pride in the patria, fatherland, where they were born and raised). Even without patriotism, or even if you assume false patriotism, self-interest was still an important drive to serve; wealth could help a family scale the social ladder and service could offer them the leverage with local authorities or the crown itself.
In addition, once rallied to serve the crown, it was no longer their choice whether or not to fight. Failure to fight, if Spain triumphed, would likely mean reprisals on themselves and/or their communities.
Just to cite some different examples, indigenous and black men also fought for the US during World War II, despite brutal policies of discrimination against both groups backed by the US government. Black leaders, like Booker T. Washington, had proposed accepting discrimination for the time being and working to show that they were worthy of being treated as equals. A position which W.E.B. DuBois and others criticized as the wrong strategy, proposing instead proactive organization and agitation (DuBois summarizes this disagreement from his point of view in The Souls of Black Folk). Going beyond race, gay men have fought in the military despite Don't Ask, Don't Tell policies, women contributed during WWII despite marital rape still being unrecognized at the time, etc. From the point of view of class, poor whites on the Confederate side had major grievances with rich planters during the Civil War, as illustrated by Eric Foner in his book on Reconstruction, but they still went to fight and die for the Confederate cause.
Obviously, if there is a shortage of willing and capable workers, a government is rarely a position where they can be overly selective. Despite thinking non-white Spaniards as lesser than whites, the Spanish government worked with the realities of colonial societies where whites were, most of the time, the minority. This meant that non-whites had to be enticed or induced to serve.
In short, a given group fighting for a country or faction does not mean that they have no grievances. Senses of patriotism can develop and/or self-interest can take over, as can the threat of violence if they fail to help.