I assume that your vehicle normally will not let you shift out of park without pressing the brake pedal.
If so, then there are about 3 possibilities.
First, the brake switch may be a two part switch. One for the lights and one for the lockout. If so, then the lockout side may be going bad.
Second, the linkage may be out of adjustment. The solenoid that locks the lever is not all that strong. In most cars, if you try to pull the lever out of park while stepping on the brake, it will bind the little locking pin and the solenoid cannot pull it out.
Try pushing the lever a little farther towards park while pushing on the brake.
Or holding the brake down and moving it back and forth gently to see if it releases.
Third, the solenoid might be releasing just fine, but the transmission park pawl is binding.
You usually find this if you are parked on a hill with a load on the drivetrain.
Also, the linkage between the lever and the transmission might be binding.
That solenoid is not all that big or loud, but if you turn on the key, and turn off all the noise makers you can, fan, radio, etc.
You might be able to hear it if you get down and put your ear next to the column while pressing and releasing the brake pedal with your hand.
If it is intermittent, then suspect the brake switch.