How can I include an external file in a post or page?

Use get_template_part to insert regularly used files throughout your site.
Example of use:

get_template_part( 'PATH/FILE_NAME' );

Where PATH is the location of the file you want to include, usually a folder within your theme/child-theme example(my-template-folder) NOTE! without leading slash.
FILE_NAME is the name of your file, WITHOUT extension, example (my-regular-code.php becomes my-regular-code).

So the above would be get_template_part( 'my-template-folder/my-regular-code' ); and this would be placed within the main code of your page, where you want to display it.

As you point out you can also use SHORTCODES, there are plenty of code examples both here and google showing the correct way to make and insert