* Engine type: This is the biggest factor. Both years used the LT1 (small-block) and the LS1 (small-block). An LT1 will fit an LT1 bay and an LS1 will fit an LS1 bay. Swapping between the two requires more work (different mounts, wiring harnesses, etc.) though it's possible.
* Specific engine modifications: Aftermarket modifications to the 1995 engine might interfere with fitment in the 1997 chassis.
* Transmission: The transmission needs to be compatible with the engine. A direct swap is easier if both cars used the same transmission (e.g., automatic to automatic or manual to manual).
In short, while the engine *might* physically fit, a seamless swap depends heavily on the specific engines and transmissions involved. You'll likely need to adapt various components for a successful installation. Expect some modifications regardless of which engine you are using.