The American militia that fought in the American War of Independence were reasonably well trained, passionate about their cause and knew the terrain they were fighting on. However, despite all of that it is still surprising that they managed to overpower the highly trained and seasoned British military establishment. It seems that the general morale of the troops played a surprisingly decisive role in this conflict.
Yes, I think that the American victory was lucky because there was one third of the amount of Spanish soldiers fighting for England, so one would think that Spain would have a huge upper hand because they have three times as many people. However, they pulled through which helped America win the overall war.
The British victory at Gibraltar in 1783 wasn't due to luck. Despite a three-year siege by the greatly superior forces of France and Spain, the British held Gibraltar by means of superior strategy, inspired leadership and naval strength. It was a remarkable victory for the British, and a setback for the American cause.
No, the American victory was not lucky, it was due to excellent general knowledge of the area. American soldiers had more to fight for than Spanish soldiers. They wanted their independence more than anything in the world and were willing to die to get it. That pushed them to victory.