I was watching Sam & Cat on tv then iCarly was on next so I watched an episode of that to see how it was like and the Sam in iCarly had the same name as the one in Sam & Cat so I was wondering if they were the same character and the two shows take place in the same place or if there was just a reference...
Sam & Cat is a spinoff of iCarly, so yes, they take place in the same world.
From the Wikipedia page:
Sam & Cat is an American teen sitcom that originally aired from June 8, 2013, to July 17, 2014, on Nickelodeon. It is a crossover spin-off/sequel of both iCarly and Victorious. It stars Jennette McCurdy as Sam Puckett and Ariana Grande as Cat Valentine.