Ignoring the obvious form factor issues for a moment.
Would a PCIe expansion card work if connected somehow to a M.2 slot?
in theory, it could probably be done.
Only if the M.2 socket supports PCIe. Not all of them do. Some are just using the SATA III interface but not the PCIe.
yes, but how many sockets these days dont have PCIe support?
It's not impossible. It's just not very practical. But there's been all sorts of wonky solutions over the years for a variety of use cases.
Generally motherboards should have native PCI-E slots that would make a m.2 to PCI-E adapter sort of pointless. My other concern would be does the m.2 interface deliver as much power as a standard PCI-E x2 or x4 slot? Given the intended purpose of m.2, and the low power requirements of SSDs I would imagine that it wouldn't. I don't know for sure, but in that case, you would be pretty limited from that angle too.
If socket supports PCIe then yes you could do it. Double check with mobo specs/manual regarding compatibility - not just the slot itself but the device that will occupy the expansion card.