You know what you know by comparing what you know vs. what you observe. You can make observations in many ways: by seeing that your code fails to produce the results you predicted; by educating yourself with relevant material (which is typically just reading about other people's observations); and by interacting with other observing individuals who are also formulating what they "know". What you "know" should be subject to change every day. Tomorrow you may make some observation that contradicts something you know. How you reconcile what you know with what you observe is a key factor in learning. (Throwing out the offending observation in favor of your "knowledge" is called "denial"! Or, in some cases, "faith".)
There are no scientific "laws". Scientific laws are just statements that science makes that seem to agree with our observations. Because we have accumulated a vast amount of observations about, say, how the pressure of a gas relates to it's volume, we get Boyle's Law. But it's not a law ... just a statement that fits our observations and has held true for a large set of observations. Tomorrow we may make some observation which conflicts with Boyle's Law, and so we will have to throw out Boyle's Law and come up with something that fits the observations we have.
So it is in the Monastery.