Why does the word "inadvertently" mean "not knowingly"?

Why do you think inadvertently means unknowingly? It doesn’t. It means, in the OED’s definition, ‘without due attention or thought; inattentively, heedlessly, carelessly; hence, unintentionally.’

The root meaning of words derived from Latin advertere is ‘turn or direct towards’. Advertent means ‘intentional, deliberate; conscious’, because in being advertent we pay attention to something, that is, we turn our minds towards it. An advertisement turns our direction towards the product or service that the advertiser is promoting.