In law, there is an old saying, "ignorance of the law excuses not".
This common doctrine likely originates from Leviticus 5:17 - “If anyone sins, and does any of the things which YHWH has commanded not to be done; though he didn’t know it, yet he is guilty, and shall bear his iniquity."