It is usually a matter of how many contacts you can fit without violating DRC rules.
For a small inverter using minimum size transistors one or two contacts per drain/source/gate is often enough. But manufacturing reliability might improve when 2 contacts are used. That might increase the size of the cell though so in many logic gate libraries only one contact is used.
There are many compromises to consider when layouting circuits including logic circuits. The "ideal" layout does not exist. Likewise there is no "ideal" number of contacts to be placed. It is always a compromise. Only experienced layouters know what makes a good compromise.