I connected the black and red wires to a double 30 amp breaker . What do I do with the white and ground wires?
Call an electrician, if you're asking these questions you don't have the basic knowledge required to complete this safely and properly.
Without additional details it's literally impossible to provide guidance to you. There's many variables here such as if this is a standard main panel vs a sub panel and the type of water heater you're installing. You also didn't include the wiring gauge you're using or the input voltage from the utility (120V , 230V, 240V).
Dangerous and improper wiring kills over 500 people every year in the US, don't be one of them.
If the breaker is one with a white pigtail then the white wire goes into the neutral terminal and the pigtail to the neutral bus where all the other white wires are going. Otherwise the white goes to the neutral bus.
The bare wire goes to the ground bus where all the other bare wires are going.
If it is a main panel then ground and neutral bus will be bonded to each other and it is acceptable to put both on the same bus.
I'm assuming you've turned off the panel first. It sounds like you might have hooked up the breaker first (I've seen some crazy folks hook the breaker up and then attach it to a live bus... which I really don't recommend). On the off chance you didn't cut power first, you have to cut it now. Your neutral bar will not de-energize otherwise and there's enough there to give you a serious shock..
Your box should have both a neutral and ground bus in them. Look for where the other white and bare wires are going to.
There's a small chance they go to the same bus, but that's not normal. If they go to the same bus, hook them both to it.
The ground wire is connected to a ground connection on the WH and the other end is connected to the ground bar in the panel. The white wire is not usually needed for an electric WH so it would not have been connected to the WH. If the heater does not need a neutral, then properly cover each end of the unused white wire (i.e., the end at the WH and the end in the panel).