Spain's role in the independence of the United States was part of its dispute over colonial supremacy with the Kingdom of Great Britain. Spain declared war on Britain as an ally of France, itself an ally of the American colonies, and provided supplies and munitions to the American forces.
Spain provided supplies such as food, water and weapons. Their alliance with france allowed them to double ally. Getting supplies from france and giving them t America.
Hope this helps!