Take a look at the federal election laws. Any expenditure to further the election of a candidate is considered a contribution. It does not have to be a contribution to the candidates campaign fund. It can be hush money, rental of a town hall for a rally, a billboard, or anything of value as long as the purpose was to help elect the candidate.
For an individual the limit on a camaign contribution in 2016 was $2700. Cohen pled guilty of making excessive campaign contributions and attempting to hide it.
Cohen was Trump’s lawyer, acting as his agent in paying hush money and hiding the payments by using a shell corp rand a bank account with a fictions owner. There was a clear understanding that Trump would pay him back after the election which he did.