I see that there are a few transactions that have many key images for each of the 11 ring members. But there are also a few with a lesser number of key images. How does this happen?
[Though this wasn't always the case, due to a bug that was discovered and patched prior to any exploit] there is a single key image that can be derived for each output on the blockchain. The output's recipient is the only one who can create that key image using their secret spend key. When you spend your Monero, your transaction must attach the key image and sign the transaction (another use of the secret spend key) in order to create a valid transaction.
Any key images you're seeing on a block explorer represent the proof that a particular output is able to be spent, plus it prevents that output from being spent again because the key image remains in the key image list.
How is the number of key images for transaction selected?
There is a ring for every output being spent and there is a key image for every ring.
More in this answer.