Your shift interlock feature, which requires you to step on the brake pedal to prevent unintentionally shifting out of Park, could be malfunctioning. Alternatively, the shift cable or linkage connected to the shift lever could be gummed up with grease or corroded so that it can't operate freely.
If the interlock switch is worn and not fully releasing, or the brake lights don't receive a signal from the brake light switch to illuminate, you won't be able to shift out of Park.
Grease, dirt and moisture can collect in or on the interlock and brake light switches, and on the shift cable and related parts, hampering their operation. When that happens, you're most likely to have problems shifting out of Park when the engine and transmission are cold, such as after the car has sat for hours. After the engine gets warm — and other parts get warmer, as well — the goo might become softer and make it easier to shift out of Park.
Most cars have a means of overriding the shift lock so you can drive the car to a mechanic rather than have it towed: A small door the size of a fingernail is often found on the console next to or close to the shifter itself. After prying this cover off, one can insert a screwdriver or key and press down to release the lock. Vehicles with column shifters may hide the release on top of the steering column or on the bottom. Your owner's manual will help you identify the location on your car.
A transmission that's low on fluid also can be hard to shift out of Park, though that also would likely cause a noticeable degradation in the transmission's overall performance, such as sluggish or harsh shifts.
Another possible cause is that when a car is on even a slight incline, it will put more load on the transmission parking pawl (a bar that engages teeth in a transmission gear to prevent the vehicle from rolling). This is more likely to happen if you didn't engage the parking brake before releasing the brake pedal. The weight of the vehicle rolling onto the parking pawl makes it harder to shift out of Park. To avoid this, engage the parking brake when on an incline before shifting into Park or releasing the brake pedal. That way the parking brake, not the transmission pawl, bears the load.