Database
[{/** other keys,*/tags:[{tagA:"red"},{tagB:"green"}]},{/** other keys,*/tags:[{tagA:"orange"},{tagB:"green"},{tagC:"car"}]}]
Query
db.collection.aggregate([{"$unwind":"$tags"},{"$addFields":{"kv":{"$objectToArray":"$tags"}}},{"$unwind":"$kv"},{"$group":{"_id":{key:"$kv.k",value:"$kv.v"},"count":{"$sum":1}}},{"$group":{"_id":"$_id.key","value":{"$push":{"k":"$_id.value","v":"$count"}}}},{$project:{val:[{k:"$_id",v:{"$arrayToObject":"$value"}}]}},{$project:{res:{"$arrayToObject":"$val"}}},{$replaceRoot:{newRoot:"$res"}}])