How do I install a fan when the electrical box has 2 white and 2 black and 2 ground wires?
Usually only the receiver is attached to the mains. One set of receiver wires (usually black/white/bare or green) go to the circuit and another set of receiver wires, often with two hots (black, red or blue) go to fan and light separately, and then white to white and ground to ground.

If there is a receiver, the fans own wires should generally NOT be attached to the mains.