Minimize freezing of brake cables
They are likely freezing because water is getting into the space between cable outer (cable housing) and the cable inner (the wire brake cable). Water expands as it freezes, in doing so it takes up more space than is available in an otherwise the restricted system.  Because the cable housing is relatively inflexible to expansion (it needs to be otherwise your brakes would be mushy) this ends up binding the inner brake cable causing your brakes to metaphorically and literally freeze.

About the only way to fix the freezing is to prevent water from getting into that space.  Adding oil or grease will likely not be enough to displace all the water, and as the remaining water expands when turning into ice you are left with the same problem.  

As a quick fix you can bring your bike into someplace above freezing and hang it so that the water can drain out of the cable housing.

A more permanent fix depends on whether or not you can fully seal the system against water ingress. This depends on the type of brakes you have and how the brake cable is routed. I have only ever experienced freezing of brakes in sub-zero conditions on a bikes that were using full length brake housing, with the rear mechanical disc brake was mounted on the lower chain stay with no real seal between the brake housing and the disc caliper.  Rain water would slowly drip into the cable housing from the open end at the caliper and pool somewhere mid-chain stay.  Then when the weather dropped below freezing the rear brake would freeze solid.

The only to prevent this is to have some sort of seal that prevents water ingress into the housing from happening (e.g., see below)



If you have another type of brake system or a different cable routing from what is pictured above I would need to see a picture to try and diagnose how water is entering and remaining in your brake housing.

UPDATE

From your picture your cable boot on the rear brake appears to be dislodged. This will allow water to enter the system, where it will pool in the cable housing just after the brake noodle (see figure below).