The Captain can put anyone he wants in charge of a certain department on his ship.
It still doesn't make sense.
NCO's are not trained and qualified for "command", he would be "commanding" a large engineering staff, most likely including people who were trained and qualified to command.
Are you familiar with CPOs in the Navy? They can be responsible for supervising very large numbers of people. There's nothing magical about "command" that only an officer can do it.