Install of tankless water heater
Not likely will it be possible to replace the two 30A breakers with 40A breakers.

The wire size (AWG) for a 30A circuit should be 10 gauge. Proper wire size for a 40A circuit is 8 gauge if the run from the service entrance to the tankless heater is a reasonably short distance. 

So do not simply replace the breakers like you asked. The breaker's primary function is to protect the wiring from over current so as to prevent a fire in overload or short circuit conditions.