I just wanted to confirm, is it true that for a bitcoin (public) address it should always have a '1' in front of it. For certain transactions though I see that there is a '3' in front. How is this possible, and why is it a '3'?
Addresses starting with the number “1” use the P2PKH (pay to public key hash) whereas an address that starts with the number “3” uses P2SH (pay to script hash).
In the first the script only check if the signature is valid by comparing a hash of your public key (the address starting w/ 1) and the digital signature, both created by your private key.
For the P2SH (used by multisig transaction) its slightly more complex where different scripts need to produce the same results when executed with the right cryptographic parameters.
more here What is P2PK, P2PKH, P2SH, P2WPKH - ELI5
A Bitcoin address prefix is a function of the locking script type for a particular transaction output.
Older Bitcoin Pay-to-Public Key Hash (P2PKH) scripts are associated with addresses that start with the number 1, resulting from a one byte version prefix prior to base58check-encoding being set to 0x00.
Newer Pay-to-Script Hash (P2SH) transactions start with the number 3, resulting from a one byte version prefix prior to base58check-encoding being set to 0x05.
Examples of P2SH are singe single P2SH signature addresses, multisig addresses, and nested P2SH(P2WPKH) that resulted from segwit to maintain backward compatibility with older wallets that are not explicitly segwit-enabled to wallets that are segwit-enabed. Such addresses conform to the BIP 49 hierarchical deterministic scheme.