I'm reading about the Tripoli Wars initiated by Jefferson, who decided that going to war would be cheaper than paying ransom to pirates. Though many prisoners were released for a fee, I've read some were sold in to slavery.
Who were the people being attacked by pirates? Were they European and American primarily? And if they were being sold into slavery, what was their experience like? Does this mean that there were white slaves in Africa?
There were in fact white slaves in Northern Africa; and equally there were Muslim slaves in European galleys.
In fact a great book on this topic just came out a couple years ago; "Captives and Corsairs" by Gillian Weiss.
To answer your questions; pretty much anyone could be attacked by pirates; both muslim pirates, but also Christian pirates were plying the waters during this time period and before. Common people could end up as galley slaves serving on the ships that captured them, merchants and upper class captives would be more likely to be actively ransomed back. The experience of the captives varies wildly- some might convert to Islam and stay a servant, some got their freedom and set up as merchants in their new home country, many were ransomed back to Europe- in fact there were Christian organizations (or religious Orders) who maintained missions/offices in places like Tripoli in order to ransom back captive Christians. The price of the ransom would be raised back in Europe, often from the town the captive came from (which at least in France was often in Southern France), and then shipped over. The ransom was really what most of the pirates were looking for.
I would caution, that while there were definitely white slaves, there is a qualitative difference between the type of slavery they would have been subjected to and the type of slavery that was going on in the Americas- this was not chattel slavery by any measures (though things were not jolly for people working in the galleys). Freedom was a very real and likely option, and people with skills were generally employed in their fields.