It is because you are paying not just for a product, but the value of it plus the training and experience of the developers.
The company or developer will usually bill you hourly for their services. This can include the original development as well as services rendered later for making changes to the appearance, content, or features.
They may also have overhead costs for the building, equipment, software, staff, etc. that they also have to factor into pricing.
Just because a developer is expensive, it doesn’t mean they are very good or that your investment will last you several years.
Every company is different and not all web developers are equal. Some are highly skilled in certain areas, while lacking in others. Some developers are dishonest, inexperienced, or just terrible programmers. Do your research and go with a developer you can trust.