The price of the tank is dead-on. I’m not as familiar with the price of expansion tanks, but that’s probably not out of line. If the $300 is for installation, that’s very reasonable, but if it’s for delivery, that seems too much.
The expansion tank will be a permanent part of your system. You can learn more about them in Tanklets under Temperature/pressure relief valves. You might also call your city and make sure it’s really code to have one.
You can also test your current system with a water pressure gauge to determine whether you have the thermal expansion that makes such a tank needful. Also, if you search on thermal expansion, you’ll find other posts here in The Tank relating to that issue.
PS — Read the other sections of the site about optimizing a new water heater. There are things you can do to increase a tank’s life that are a lot easier when it’s just out of the box than after it’s installed.