loop through posts and display inserted media and post title as a link

I took a quick peek at the other question referenced in other comments, and the gist of how you loop through attachments there meshes with what is shown in the wp_get_attachment_image documentation example. In a nutshell, any attachments on a particular post will reference that post by ID.

In particular, it’s crucial to understand that attachments are also posts themselves of the post type attachment. Inside your main loop, you’ll get your attachments by running a nested query for all attachments whose post parent is equal to the ID of your outer loop’s post:

// Our main (outer) query:
while(have_posts()) {
    the_post();

    $nested_query = new WP_Query(array(
        "post_type" => "attachment",
        "post_status" => "inherit",
        "posts_per_page" => -1,
        "post_parent" => get_the_ID()  // attachments belonging to the post we're looking at
    ));
    $attachments = $nested_query->get_posts();  // get an array of post objects for each attachment
    foreach($attachments as $att_post) {
        printf("<a href="https://wordpress.stackexchange.com/questions/163907/%s">%s</a>", wp_get_attachment_url($att_post->ID), get_the_title());
    }
}

I doubt the above does what you want it to, primarily because I don’t think you want to echo an anchor for every single attachment that has the post title for its text. However, for illustrative purposes, this is how you could loop through attachments nested within a post loop.