The memory foam you got is meant to be a topper for a regular mattress, not the mattress itself.
Foam comes in different grades depending on the intended use. Sofa/couch seat foam is the hardest and most long lasting but some people find it too hard to sleep on - I don't...I fall asleep regularly on the sofa...
Mattress foam is usually a little softer than seat foam so the first thing to consider is how firm or soft a mattress you want. Now that you've already got the memory foam, maybe seat foam with the memory foam on top will suit you just fine.
I head to my closest upholstery shop for foam because they actually know what grade stuff is, unlike most staff in someplace like JoAnnes' where the staff is trained to cut yard goods, not identify foam grades!!
Some mattress places also carry raw mattress foam (not already encased) but again, may not be fully trained.
I've slept on 4" of mattress foam for 2 decades now and it's past time to replace the mattress.
Oh and if you buy a slab of foam and need to trim it to size, either an electric carving knife or any serrated knife works best.