I'll take the high road here and try to be helpful.
Any physician is, with extremely limited exceptions (maintenance therapy for drug abuse is the only one that I can think of), able to write prescriptions for any drug they see fit to best serve their patients. Although a cardiologist does indeed specialize in disease of the cardiovascular system, it isn't inconceivable that a patient seeing a cardiologist might have a chronic pain condition.
Here is one scenario: a patient with breast cancer receives doxorubicin and develops heart failure secondary to therapy. She now sees the cardiologist to manage her heart failure, and he also prescribes pain medication to deal with residual pain. Or another one: a patient is in pain, and seeing a cardiologist.
Might the patient be better served by seeing a pain management specialist? Maybe, but it might also be another physician's appointment to schedule while juggling a busy life and chronic pain...and result in the same prescription.
Understand that the patient might be seeing a cardiologist, but that cardiologist is a physician first. Physician's treat patients to the best of their ability.
Off the soapbox.