For Royal Caribbean, someone in each room has to be at least 21 years old. If you are 21, you can have roommates who are under 21, but those under 21 can not be booked into a cabin without you.
Sometimes exceptions are made for children of parents who are in a connecting cabin.
For Carnival, the same rule applies except the age is 25, and not 21. Royal Caribbean used to require someone be 25 too, but they lowered it to 21 a couple of years ago.