In a 4-stroke engine, the piston goes up and down four times for each complete combustion cycle. The first stroke is called the intake stroke, and it is during this stroke that the piston moves down and pulls air and fuel into the cylinder. The second stroke is called the compression stroke, and it is during this stroke that the piston moves up and compresses the air and fuel mixture. The third stroke is called the power stroke, and it is during this stroke that the compressed air and fuel mixture is ignited by a spark plug and the resulting explosion forces the piston down. The fourth stroke is called the exhaust stroke, and it is during this stroke that the piston moves up and pushes the exhaust gases out of the cylinder.
2-stroke engines are different from 4-stroke engines in that they go through only two strokes for each complete combustion cycle. The first stroke is called the intake and compression stroke, and it is during this stroke that the piston moves down and pulls air and fuel into the cylinder and then moves up to compress the air and fuel mixture. The second stroke is called the power and exhaust stroke, and it is during this stroke that the compressed air and fuel mixture is ignited by a spark plug and the resulting explosion forces the piston down and the exhaust gases are pushed out of the cylinder.
So, to answer your question, dirt bikes can have either a 2-stroke or 4-stroke engine. 4-stroke engines are generally considered to be more powerful than 2-stroke engines, but they are also heavier and more complex.