A junction box performs several essential functions:
Encloses the wiring connections and protects them from physical damage
Provides a means for mounting the electrical device and securing the electrical cable(s) serving the device
Prevents accidental contact with live wires and terminals
Protects against fires by containing live wires that may come loose from the device
If you intend to use any device without a junction box, it's critical that its wire connection system serves all these necessary functions provided by a standard junction box. For example, if you have a light fixture that doesn't need a box for mounting, but the wiring connections are not protected by some kind of cover, then you can't use the fixture without a junction box. Or, if a fixture meets all of the criteria of a box but lacks a cable clamp, don't use it without a box.