This is a great question, and you are right that it is sometimes difficult to distinguish between kidney pain and low back muscular pain, since both pains originate from basically the same region of the body.
However, there are a few things that are helpful to distinguish the two pains. First, muscle pain
tends to be lower in the back, close to where the hipbones are, and located just to either side of the spinal column. Often, when you press on the involved muscle, the pain will be worse, or the muscle will feel 'tender'. Also muscle pain tends to be worse with bending or movement.
Kidney pain, on the other hand, tends to be deeper and higher in the back, located under the ribs. The pain tends to be more difficult to describe and less like to feel like a cramp or muscle spasm. Also, there may be radiation of kidney pain down the leg into the groin.
If you have pain in your lower back, you should definitely see your primary care doctor
as soon as possible. They can examine you closely and help you figure out what might be the cause and which treatments might be necessary.