Does the version prefix of an address force the type of transactions the address may treat? A Bitcoin address is created with Base58Check encoding and it requires a version prefix, such as 0x00 for a P2PKH(pay-to-public-key-hash) address, 0x05 for a P2SH(pay-to-script-hash) address.

Does the version prefix of a Bitcoin address force the type of transactions the address may treat, or is it just for indicating the appropriate one?

In other words, can one do:


Generate a ECDSA key pair.
Create a Bitcoin address with it, with a version prefix 0x05.
The generated address is a P2SH(-like) address; at least its format is.
Make a P2PKH transaction with it.
Since addresses are only human abstractions and do not actually exist on the network, no, addresses do not force the type of transaction that you can create with the data provided in an address. There would be no way to enforce that. However creating a transaction that does not use the type that the address specifies is a good way to lose funds because the way to spend those outputs are different.

So yes, you can take a P2SH address and create a transaction with a P2PKH output that has the same data that the P2SH address provided. But the person who controls that P2SH address is not going to be able to spend the coins from the P2PKH output since the requirements for spending will be different.