But was it just the British? You might notice that a lot of the other countries from the map above where homosexuality is illegal were French colonies:Wikipedia
And many Dutch, Portuguese, Spanish and Belgian ex-colonies have high penalties for gay sex too. However, in these cases colonialism isn’t the culprit. Nearly all of the non-British former European colonies with stiff penalties for homosexual relations instituted them after independence.