If there is a legal conflict, EU law trumps all, the same way federal law trumps local law in US. The highest court is always an EU institution. EU countries give up part of their sovereignty in specific legal areas, like market competition regulations. They can always leave if they want.
This depends, though. The EU does not have laws covering everything that national or local law might cover in its member states. In many cases the EU court of law is more like the US Supreme Court in that it is more about establishing whether a given legal decision is compatible with the basic law (e.g. human rights). It's more about setting the boundaries within which member states can make their own laws. So national law might say "X is illegal" and EU law might say "nations can say X is illegal" (or that they can't).