Count the contiguous submatrices Migrated from chat
Given two non-empty non-negative integer matrices A and B, answer the number of times A occurs as a contiguous, possibly overlapping, submatrix in B.
Examples/Rules
0. There may not be any submatrices
A:
[[3,1],
 [1,4]]
B:
[[1,4],
 [3,1]]
Answer:
0
1. Submatrices must be contiguous
A:
[[1,4],
 [3,1]]
B:
[[3,1,4,0,5],
 [6,3,1,0,4],
 [5,6,3,0,1]]
Answer:
1 (marked in bold)
2. Submatrices may overlap
A:
[[1,4],
 [3,1]]
B:
[[3,1,4,5],
 [6,3,1,4],
 [5,6,3,1]]
Answer:
2 (marked in bold and in italic respectively)
3. A (sub)matrix may be size 1-by-1 and up
A:
[[3]]
B:
[[3,1,4,5],
 [6,3,1,4],
 [5,6,3,1]]
Answer:
3 (marked in bold)
4. Matrices may be any shape
A:
[[3,1,3]]
[[3,1,3,1,3,1,3,1,3]]
Answer:
4 (two bold, two italic)
Brachylog (v2), 10 bytes

{{s\s\}ᵈ}ᶜ


Try it online!

I like how clear and straightforward this program is in Brachylog; unfortunately, it's not that short byte-wise because the metapredicate syntax takes up three bytes and has to be used twice in this program.

Explanation

{{s\s\}ᵈ}ᶜ
  s         Contiguous subset of rows
   \s\      Contiguous subset of columns (i.e. transpose, subset rows, transpose)
 {    }ᵈ    The operation above transforms the first input to the second input
{       }ᶜ  Count the number of ways in which this is possible