SG, the regulations are in place to prevent precisely what you want to do. In the US, anyone can get married regardless of immigration status. But not at all easy to obtain a green card after marriage if one entered the US on a tourist/visitor visa.

In fact, if the foreign spouse applies for permanent residence within 90 days of entry as a non-immigrant, it is quite easy for US Immigration to accuse the individual of Misrepresentation because s/he did not state on the tourist visa application that there was an intention of marriage. In many cases, this would require the foreigner to apply for a Waiver of Inadmissibility, including evidence that it would be an extreme hardship for the US citizen if foreign spouse were not allowed to remain in America, or if the American had to leave the US to live abroad with his alien spouse.

In US law, the correct, legal course of action if a marriage does take place in the US, is for the alien spouse to return to home country and wait for processing of the spouse petition. May take a year, but it's usually fail safe.

Also about a year for processing of fiancee cases (foreigner never in US previously), and same-sex fiancee cases have had a high success rate in the US.