This was probably drawn in Illustrator. My guess with this one is the text FBTO is a clipping mask making everything outside of it transparent. In a layer underneath it looks like they have made a layer with a gradient mesh. They've manipulated the mesh to create a rainbow effect and, as part of this effect, its become distorted a bit to created that slightly odd effect on the gradient. Doing it this way would make it vector.
The alternative is that it was drawn in Photoshop, or some similar package, with a layer mask the shape of the font. The artist would have then probably have hand painted the gradient making that odd effect.
So, yeah, to simulate this effect best look into how to use the 'gradient mesh' tool in Illustrator.
The second example is slightly more complicated as it involved several layers within the clipping mask that are over lapped the have a gradient mesh applied with some of the points on those gradient meshes being transparent.