Hey Mohsin,
in a microflow,
Before creating a new object associated with itself,
First, retrieve the total number of objects associated to it, and using aggregate list activity, count the total no. of objects, Now,
Apply a decision box and check $count<=4, if true, go ahead and create an object, and if false, give a error message as per your choice.
Let me know if you face any issues.
Hope it helps!