What happens if I got a kidney from someone who later was diagnosed with kidney cancer?

Good Question. This has happened. Kidney cancer may have a genetic predisposition, and a person has a 1-2% chance of having bilateral kidney cancer. So if a donor (assuming this to be a live donor) developed kidney cancer in the remaining kidney, the recipient of the donated kidney should have it screened with an appropriate imaging study such as ct scan to be sure there is no mass in the transplanted kidney.
It depends on timing. If the kidney cancer was diagnosed soon after donation, it may be prudent to remove the transplanted kidney because it might contain cancer cells which could ultimately harm the recipient. If the donor develops cancer in the remaining kidney long after donation, it's unlikely that the transplanted kidney would also develop a cancer but greater surveillance would be warranted.