16" center bracket to 24" center framing
The other answer given so far describes a solution where the tankless water heater is being installed in an area where the studs are open and not covered. There are instances where the studs are not open and may be covered with drywall (a.k.a. sheet rock). It this instance the installation of extra studs or cross blocking is not so easy and other methods are called for. I will describe two options:


You can cover the entire wall area where the brackets will be attached with a piece of 3/4" plywood. This may actually need to extend beyond the end of the bracket if the existing studs in the wall are farther away from the bracket mounting points. Secure the plywood to the wall surface using screws through the plywood and into the existing studding structure. Then mount the bracketing to the plywood. With proper size pilot holes for the screws the plywood does a really good job of holding the screws.
An alternative solution would be to mount two horizontal 2x4s or 2x6s flat on the wall centered vertically where the tankless heater brackets will be located. These cross members are attached with screws at each existing stud location. They may have to extend longer than the width of the bracketing if the next stud is further over from the mounting location. Once the cross members are secured the bracketing can be screwed into the cross members.


Note: Either of these schemes can also be used on a wall that has open studs. In fact applying one of these techniques could even be easier to install than extra studs and blocking between existing studding.