One thing you will probably run into is a color difference. We did this on a rental we had. The carpet was 3 years old and we needed to repair an area. To our surprise the carpet had faded. So before you do it, you might want to set the repair patch out in the sun for awhile.
I suggest not to cut a square. It may be more noticeable if you do. Make sure the nap is running the same direction.
Cutting and making it fit can be easy or tricky depending on the type of carpet. I'm going to let the pros answer that one for you. Good Luck