Why should you use a connector instead of a pigtail on your sensor?

Isn’t purchasing sensors with M12 connectors expensive? If I bought a pigtail, what are my options?

Items used in this video: