We can control tcp/udp traffic using router. Then why is it in Network layer and not transport layer?
Because routers are real concrete devices, not theoretical constructs.  They aren't limited by layering diagrams.  Layering is a form of abstraction, which is a convention; there's nothing that prevents a device from inspecting and acting on the rest of the packet.

Separately: layering diagrams are a model, but not a perfect one.  Real devices violate layering from time to time.  The OSI 7-layer model is especially approximate -- don't take it too seriously.  See, e.g., Till which layer does the loopback packet goes? and can network layers communicate between each other?.