They really are nearly the same thing but you are asking why in one instance hand how in the other.
A friend discover is you know a fact that they wouldn't think you would need to know but they would say "why do you know that?"
If you know a secret they would say"how do you know that"