why is output different of counting files?

Solution 1:

tree
# Also output directories but not hidden files
.
├── Directory1
├── Directory2
├── File1
└── File2

tree -a
# Also output hidden files and hidden directories
.
├── Directory1
├── Directory2
├── File1
├── File2
├── .Hidden_Directory1
├── .Hidden_Directory2
├── .Hidden_File1
└── .Hidden_File2

find -type f
# Files and hidden files
./File1
./File2
./.Hidden_File1
./.Hidden_File2

tree -aifF | grep -v '/$'
# Output files and hidden files
.
./File1
./File2
./.Hidden_File1
./.Hidden_File2

Source : How to make tree output only files?

The -i and -f arguments cause tree to output full paths on each line, rather than indenting. The -F argument causes it to append an / to directory names, which are filtered out by the inverted grep (grep -v '/$').

man tree
-f     Prints the full path prefix for each file.
-i     Makes tree not print the indentation lines, useful when 
       used in conjunction with the -f option. Also removes as much 
       whitespace as possible when used with the -J or -x options.