Affordable housing, by its very purpose, is intended for households not able to afford market housing. So, these programs typically set maximum income limits (adjusted for the size of the household) for the occupants of the units. Also, it is fundamental that the size of the household must match the size of the unit. (Large households are not allowed to squeeze into small units, nor small households take advantage of large units.)
In the case of affordable ownership units, some programs add other eligibility criteria. For example, they might limit the purchase to first-time buyers, or households who have not owned a home for a number of years. They might also put limits on assets that the purchasers can have, in order to weed out those capable of buying a market unit.
Where there is a big demand for these units (as there generally is), the municipalities select the potential occupants from the pool of eligible candidates using either a lottery or a “first-come/first-served” process.