Yes the Direct Drive Trainer (DDT) should work fine with your bike and yes you're on the right path...
You will need a 7 speed cassette and 4.5mm of spacers for a 7 speed cassette to fit on a freehub designed for 8/9/10 speed cassettes. If the DDT has an 11 speed freehub you would need an additional 1.85mm spacer and maybe a 1mm spacer. Yeah, lots of spacers...
Before buying your DDT make sure it supports your bike's rear wheel spacing: 130mm and 135mm are the most common. BUT some of the older 7 speed bikes also used 126mm. An inexpensive Walmart bike likely has flexible tubing in the rear triangle so even if yours measures 126mm it could be forced to fit 130mm. But just to be safe, remove the rear wheel and measure the inside distance between the dropout faces. If the bike isn't 130mm then you should also see if it is easy to pull apart the dropouts 5mm. If the frame is made of aluminum frames tend to be much less flexible than steel frames.
Also note that since you're going to want to reinstall the rear wheel at some point you're not trying to permanently bend (aka "cold set") the frame but rather just coercing the frame to fit the 130mm trainer. Steel in particular is very forgiving so flexing it a bit won't do any damage.
Yes the number of teeth in the largest cog does matter. If the new cassette has a lot more teeth then the chain may be too short and need replacing. Alternatively you can use the too short chain and just make certain to not shift onto a rear cog which is too big. Doing so typically causes the rear derailleur to bend and get forced into the rear wheel. Never a happy ending...
7-speed cassettes and freewheels have the same pitch:
pitch = width_of_cog + width_of_spacer
So whatever shifters you have on your bike should work fine with the 7-speed cassette instead of freewheel.
The adjustment for shifting may be off a bit so don't be surprised if you have to do some derailleur adjustment.
There are bicycle co-op's and other similar bicycle advocacy organizations which recycle and rebuild donated bikes. If you have one nearby they should be able to provide a very inexpensive used cassette and maybe even some spacers.