When first introduced, tankless water heaters were marketed with one of the advantages being a great savings in energy, since they don't store hot water like a traditional tank style water heater. However, the savings is nowhere near what was marketed.
Consumer Reports did payback calculations to see how long it takes to get a return on investment for tankless water heaters. The details can be read here.
https://www.consumerreports.org/water-heaters/tankless-water-heaters-vs-storage-tank-water-heaters/
But in a nutshell, if you went from a gas tank water heater to a tankless gas water heater, it could take 22 1/2 to 27 1/2 years to save enough in energy costs to pay for the price difference. Switching from electric tank type to electric tankless is a quicker ROI of 12 to 20 years, but still not great. If you are considering tankless purely save money, you would be better to stay with a tank water heater and put the difference in a savings account.
As others who have them have mentioned above, tankless water heaters don't provide "instant" hot water. It takes them a bit to get the water up to temperature. A tank style water heater will provide hot water sooner than a tankless.
A tank also has the advantage of being able to provide hot water for more than one use at a time. For example, if your spouse starts the dishwasher while you are in the shower, the tank may run out sooner, but it can provide the same temperature of water. Most tankless are rated for a specific temperature rise at a specific flow rate. Exceed that flow rate, and the water temperature will likely drop. You can buy tankless systems that are rated for higher flow, but then you lose any energy savings. And they get more expensive.
I helped my son install an electric tankless water heater in his first home. From what had been advertised, he was expecting a 30% - 35% energy savings. What he actually saved was so little it was almost immeasurable. After a few months of ownership, he felt the only thing he had gained was additional storage space in the utility room. When it came time to put a new water heater in his current home, he didn't go tankless. Instead, he has a 60 gallon water heater. For all practical purposes, he has unlimited hot water for his family of four. And it is insulated well enough that he never really saw an increase in energy over the 40 gallon tank that it replaced.