You can save those pictures and videos someplace else. To do that select a conversation, click the circled i and scroll down to find those message attachments. Select one or more, and add them to Photos. Of course that will only add to local storage, but you can then open the Photos app and export what you want to save to external media. Finally, delete them from Photos, and you can delete the conversations that contained them.
To answer your initial question though if you use Messages in iCloud then deleting them will cause them to be deleted from all your iCloud-connected devices. Conversely if you do not use that iCloud service then deleting them only affects the Mac on which they are stored.
Explanation: Keep your messages up to date with iCloud - Apple Support