Transactions have a known calculable size when it is parsed. So you will know that when a transaction ends and the next begins.
Specifically...
- Each transaction starts with 32 bits (set of thirty-two 0 and 1 digits) that store a version number.
- Following that is a "set of 0 and 1" that tell how many bits (actually how many bytes, but you can multiply by 8 to get the quantity of 0 and 1) in the transaction inputs.*
- Following that is a "set of 0 and 1" representing all the inputs. This set is exactly the amount indicated in the previous "how many bits" value.
- Following that is a "set of 0 and 1" that tell how many bits (actually how many bytes, but you can multiply by 8 to get the quantity of 0 and 1) in the transaction outputs.*
- Following that is a "set of 0 and 1" representing all the outputs. This set is exactly the amount indicated in the previous "how many bits" value.
- Following that is 32 bits that represent the locktime.
* note, there is a special pattern to the first eight 0 and 1 values of the section that "tells how many bits". This pattern allows the program to know when it has read enough 0 and 1 to determine the appropriate value. If this section starts with 11111111, then the next sixty-four 0 and 1 are used to indicate the size of the inputs or outputs. If it starts with 11111110, then the next thirty-two 0 and 1 are used to indicate the size of the inputs or outputs, If it starts with 11111101, then the next sixteen 0 and 1 are used to indicate the size of the inputs or outputs. If it starts with anything else, then these 8 values are themselves the indication of the size of the inputs or outputs, and there is no need to use any additional digits to determine that size.