How does one get the KW number?
Good question. If you're buying a property, then they should give you the number without any problems, because a reluctance to do so suggests that they're up to no good.
It's worth bearing in mind that some properties don't have a KW number, but you can apply for one. As far as I know, you need the KW number to sell anyway.
For your own property, it might be on the akt notarialny, or you can get it from the Urzad Miasta for a small fee. For someone else's property, it might be possible to get if you have a valid reason to have it. I certainly obtained several in the past by merely paying the right fee and writing a letter.