Why 4 GB pendrive store data 4GB only?

Because that is the maximum storage on the chip inside your pendrive that be stored. if you had a 12 GB chip on your pendrive and a code that altered the storage parameters then you could have a 12 GB pendrive