I believe you are already aware of the mechanism of crankshaft working and the kinematics associated with the rotation and energy storage in flywheel.
Essential equations can be found in any books on theory of machines.
Focusing on your question, I believe you want to know how a flywheel is mechanically connected to the crankshaft.
Flywheel is just a metallic disc which stores rotational kinetic energy form crankshaft. It is connected with help of bolts to the crankshaft. No. and size of bolts depend upon the size of flywheel.
Now in power stroke the rpm of crankshaft tends to increase due to high amount of force on piston, which in turn tries to rotate the crankshaft. This generates torque on the crankshaft.
Now the flywheel is essentially a disc which has high Moment of Inertia, and hence it can absorb high amount of energy without much change in rpm. In power stroke while piston tries to increase the torque available at crankshaft, this flywheel absorbs the energy. Both flywheel and crankshaft has positive engagement( due to bolted connection) and hence both rotate with same rpm. In this way there is gradual increase in rpm.
When the power stroke is over, flywheel keeps the crankshaft rotating due to its high Moment of Inertia, which does not slow down easily even when there is no flow of power.
Hence flywheel only resist the change in Rpm, whether it is increase in rpm in power stroke or tendency of rpm to decrease in rest of the 3 strokes.
In this way the engine operation becomes smooth.