It's on purpose. Gun oil is a petroleum distillate. Petroleum distillates react with black powder (and to a lesser degree black powder substitutes) combustion by-products to form a tar like material that is difficult to clean from the gun.
In practice there are areas in the action parts of revolvers and the lock parts of single shot guns that see little if any combustion by-products, and in those areas limited amounts of gun oil would be ok. However, it's generally best to just keep the gun oil away so that it doesn't inadvertently find it's way into an area where the reaction could occur.
There are a number of mineral oil based lubricants and corrosion preventatives that work as well as gun oil and which do not react with the combustion by-products, so their use is recommended in place of gun oil.