Often machines do have an external source of energy but it is not obvious. For example it is possible to make a machine that works by using the small changes in the pressure of the atmosphere as the weather changes. Such a machine does not violate the first law of thermodynamics because there is an external energy source. A barometer that shows the pressure changes on a dial is an example of such a machine. The problem with such machines is scale. In order to produce useful power outputs they need to be enormous and that usually makes them impractical or uneconomic.
There are also machines that do seem to have a 'free' source of energy. Examples of this are machines that use the air past a vehicle or speed bumps in the road that compress and generate power. Of course in both cases the energy is coming from the vehicle's fuel via its engine. Both methods are an extremely inefficient ways of generating energy. Read More >>>
It is also theoretically (but probably not practically) possible to build a machine that does not violate the second law which runs forever (neglecting the energy to start it moving). One example of such a machine is the planet earth orbiting the sun in the vacuum of space. One could imagine making a similar machine with a rotating sphere suspended on magnetic bearings in a vacuum that rotated for a very long time without any external energy inputs. Gyroscopes used in inertial navigation systems get close to this. The problem with such machines is that they cannot do useful work. As soon as you connect them to something they will start to slow down. It is impossible to produce a truly frictionless bearing so Gyroscopes need some form of motor to keep them going, and the earth is slowing down all the time as it is subjected to the drag of the sunís magnetic field and the gravitational attraction of the other planets. However there is no immediate cause for alarm as it is going to take many millions of years for this to have any significant effect. Here are some links to typical Perpetual Motion Machines and machines without an obvious source of power.
Unbalanced Wheels Car Wind Generators Feedback Generators