A baron is a mayor that has a contract with the duke to find forces
My understanding is the Baron is the military might in the County. He pays taxes to the Count and buys land from him.But the Duke gives him things to help defend the area. Of course I see a potential for conflict in this in regards to where the barons loyalties lie.
Barons are made by dukes and given the task of raising an army and defending a position. While they do interact with counts they would be bannermen to the duke.
Everyone is a Mayor until contracted directly with a Duke whom then elevates the persons title to a Baron based on a contract. The settlement of a Baron is military focused with barracks, training and defensive positions.
Baron's typically report directly with their Duke that have contracted with. They do pay taxes to the Count but given their role in protecting the local area makes sense for the Count to support them with land and low or no taxes.
Baron's can act as judges for the Duke's Courts and receive a stipend to keep a core of trained professional soldiers and reserve trained, ready for the call-of-arms.