No, ciphertext of modern ciphers is supposed to be indistinguishable from random. That means that the algorithm cannot be automatically detected.
Generally the algorithm is preset (hardcoded) or it is a configuration parameter, established ahead of time. It may be established at runtime or saved with the ciphertext, but note that adversaries could possibly also change the algorithm before it is used.
Note that for instance AES is a block cipher, it is not a general purpose cipher by itself. For that a mode of operation of the block cipher is also required. In other words, just specifying the block cipher is not enough. There may be other parameters that need to be established.
As already mentioned in the comments, the protocol defines when the algorithm is selected.