This problem is sometimes called the room assignment problem or the hospital/university admissions problem. The standard approach here is to use the Random Serial Dictatorship algorithm (RSD). This algorithm is very simple, but has nice properties and even is the only algorithm (where I call algorithms that provide the same output the 'same algorithm') that has all these properties.
The RSD algorithm is as follows: pick a customer at random and assign to that customer the most preferred unit that is still available. Then, pick another customer that has not been picked yet and repeat this procedure until all customers are assigned.
This algorithm has the following nice properties:
Pareto optimality: We want the assignment to be 'efficient' somehow, in the sense that we as much as we can give the users what they want. One way to look at this is to call an assignment 'bad' if any number customers can redistribute their units such that at least one of them has a better unit and none of them have a worse unit. If an assignment is not 'bad', then it is Pareto optimal.
It is a straightforward exercise to verify that the RSD algorithm is indeed Pareto optimal.
Strategy proofness: We want that there is no way that customers can 'cheat the system' by lying about their preference. Formally, we say that a customer $c$ can successfully manipulate if there is a fake preference profile $P'_c$ such that the algorithm gives a strictly better unit according to the true preference profile $P_c$ than $c$ would get if $c$ would report their true preference $P_c$. If there is no possible way for any customer to manipulate, the system is called strategy proof.
It is easy to see that RSD is strategy proof: we only look at the preference profile of $c$ when it is their turn to choose. But then, lying only means that they might pick something that has a lower preference than all available units! So, $c$ cannot manipulate.
'Fairness' We want also to be somewhat fair, in the sense that every customer should have 'equal opportunity' to get their preferred unit. But, there are limits here. We cannot demand that each user has equal probability to get their best result: Suppose we have 100 customers and all but one customer prefers unit 1 most, but the final customer prefers unit 2. Then whatever assignment mechanism we make, if we want Pareto optimality, the final customer has a higher probability to get their most preferred unit.
In RSD, the randomized portion is there to enforce some sort of equal treatment. We cannot treat everyone the same, but at least everyone has the same chance to be first to pick their favorite, as to be second, third, etc.