They are expensive because people don't bother comparison shopping for infrequent purchases. A passport photo is something you buy once every ten years, so it's not worth the hassle to call or visit different places and compare prices. Most people just go somewhere and get it done. Therefore, a place that lowered its prices would be losing revenue without getting many additional customers.
People do price research on things they buy frequently. That is why everyday purchases, such as groceries and gas, have lower profit margins than infrequent purchases, such as electronics and furniture.