It’s dangerous to put your baby down to sleep in a regular sleeping bag because of the risk that they will either roll over or wriggle down into the sleeping bag and suffocate. The American Academy of Pediatrics recommends babies sleep on a firm surface. Also, it states the sleeping area should be free of toys, loose coverings, and other potential obstructions, including the loose fabric of a sleeping bag (source).
However, baby sleeping sacks and sleeping bags are specially designed to keep the area around the baby’s head free from potential obstructions and to prevent them from wriggling down into the bag.
For children under 2, you should only ever use a sleeping bag specially designed for babies. For children older than 2, only use a sleeping bag that is for the appropriate age range.