Ignorance of the law is never an excuse if you are found to be breaking the law. So if you think what you are doing is possibly in violation of the law you better bone up or ask a lawyer for a statement on letterhead that what you are doing is ok.
For C-level execs that is probably not going to work, but for people lower on the totem pole it may well give at least some relief. You might end up convicted anyway but with a more lenient sentence if the argument is considered believable.
There are blatantly illegal things you can do in any field of work. You need to be aware of what is and isn't within the law on a loose basis yes. Even labourers on a building site have to do some training to avoid breaching health and safety legislation (or at least to minimise the companies liability when they error).
You also need to have faith in the compliance team and senior management. If your company works in legally sticky territory like crypto doubly so.
If you are in finance or law it is a good idea to know what you can go to jail for. Engineers are people and people can go to jail for breaking laws they didn’t know about.
If you want to write code for a financial institution? You bet you should be expected to know what you are doing, and understand there are relevant laws, and also not violate those laws. It's not hard. I know the relevant laws to my domain of job.
Propably not, but a solid understanding of the rules and regulations, and legal requirements, of your field and thebindustry your working in is actually a pretty good thing.
If you work in a company where there is no one that has some idea about the laws that apply to what you do that you could check with, you would be a little concerned.