Generally speaking, affect is a verb and effect is a noun, but there are times when effect can be a noun. Here are some examples:
Affect – to change or alter something. Kamala Harris affected the results of the first Democratic debate when she went head-to-head with Joe Biden on busing. That medication affects Jim; he's going to go off it.
Effect – the end result or consequence. The side effect of that drug was miserable. The effect of all my studying was that I got an A- on my final.
So when is effect a verb? To effect means to make happen, but it is not used that often as a verb. By and large, you can consider affect to be a verb and effect to be a noun.