Explicit message length in Bitcoin Signed message the message format is:

length(prefix),prefix,length(message),message
with prefix="Bitcoin Signed Message:\n"


now I am wondering why the length(message) in the middle is needed as it should be able to just calculate it from total_length-prefix_length

Some context here: https://github.com/ethereum/EIPs/pull/683#issuecomment-358460381
It's a quirk of the original implementation of the message signing logic which was introduced in Bitcoin Core in 2011.

When the message is signed, it must be serialized before it is hashed. The serialize methods in Bitcoin Core are shared between the network, hash preimage, file, etc. serializations, most of which require that the data be prepended with a compact size uint that specifies the length of the data. Thus those methods will prepend such a compact size uint when serializing whatever data.

The implementation of the message signing logic used those same serialization methods in order to produce the preimage that would be hashed. Thus the strings must be prepended with their lengths for the hash preimage.