How [Command] and [ClientRpc] are made in that way that when you call them they notify the network to send the parameters but the code inside doesn't get executed.

I make my own HLAPI, everything works perfectly but I don’t know how they managed to create methods with a behaviour like this.

They used an IL post processor which they called the UNetWeaver which does actually replace the calls to your method depending on the role. So the ordinary method call is replaced by some extra code that actually does determine what to do. I’m not sure if they used the Mono.Cecil library which can be used to inspect and alter compiled IL code. Unity’s UNetWeaver is of course specialized for the UNet system. There are other generic weaver solutions out there. However that topic is quite advanced.

The Command and ClientRpc attributes are just attributes. Attributes do not do anything on their own. They are just metadata that is stored along with the actual class / member / parameter. So there’s always an external system that interprets that metadata. Common examples are the Serializable attribute which is often required by serializers. Though there are some attributes that are actually interpreted by the compiler during compile time. Some examples are “AttributeUsage” or “Conditional”. So Unity’s UNetWeaver actually post processes the compiled assembly and replaces the method calls with the appropriate code.